package com.ckk.eurekaclient.service.mq;

import com.ckk.eurekaclient.constants.MqQueue;
import com.ckk.eurekaclient.util.JsonUtil;
import com.ckk.eurekaclient.vo.mq.SyncDataReqVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

/**
 * MqListener
 *
 * @author momo
 */

@Slf4j
@Component
public class MqListener {

    /**
     *
     *
     * @param msg
     */
    @RabbitListener(bindings = {@QueueBinding(value = @Queue(value = MqQueue.EXCHANGE_LOCAL_STACK_INFO, durable = "true", autoDelete = "false"), exchange = @Exchange(value = MqQueue.EXCHANGE_LOCAL_STACK_INFO, type = "topic", durable = "true"), key = "#")})
    @Transactional(rollbackFor = Exception.class)
    public void listenStackInfoSync(Message msg) {
        log.info("Message:[{}}", msg);
//        byte[] body = msg.getBody();
//        String data = JsonUtil.byte2json(body, String.class);
//        log.info("dataVO:[{}}", data);
    }

}
